import { useState, useEffect, useRef } from 'react'

export default function App() {
  const [count, setCount] = useState(0)
  const isUpdate = useRef(false)

  useEffect(() => {
    if (isUpdate.current) {
      console.log('执行')
    }
  }, [count])

  const handleClick = () => {
    setCount(count + 1)
    isUpdate.current = true
  }
  return (
    <div>
      <h1>当前计数为: {count}</h1>
      <button onClick={handleClick}>+</button>
    </div>
  )
}
